package com.app.util;

import com.app.entity.User;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @author by tlt on 2021/3/13
 * 权限工具
 */


public class RoleUtil {
    /**
     * 拿到用户角色id
     */
    public static Integer getRoleId() {
        User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return user.getId();
    }

    /**
     * 拿到用户
     */
    public static User getUser() {
        return (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }
}
